FROM gcc as builder
RUN sed -i -e 's/ports.ubuntu.com/mirrors.aliyun.com/g' \
    -e 's/archive.ubuntu.com/mirrors.aliyun.com/g' \
    -e 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt update && apt install -y bison flex

WORKDIR /app
ADD gsoap-2.8  .
RUN ./configure && make -j 9 && make install \
    &&  cd /app/gsoap/samples/webserver \
    && soapcpp2 -c -n -popt opt.h \
    && soapcpp2 -c webserver.h \
    && make all


FROM ubuntu:20.04 as runner
RUN sed -i -e 's/ports.ubuntu.com/mirrors.aliyun.com/g' \
    -e 's/archive.ubuntu.com/mirrors.aliyun.com/g' \
    -e 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt update && apt install -y openssl && \
    rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/gsoap/samples/webserver/webserver /usr/local/bin/webserver
RUN chmod +x /usr/local/bin/webserver
EXPOSE 80

CMD [ "webserver","80" ]

